Skip to content

Trampolines#1777

Open
Bike wants to merge 24 commits into
mainfrom
trampolines
Open

Trampolines#1777
Bike wants to merge 24 commits into
mainfrom
trampolines

Conversation

@Bike

@Bike Bike commented May 27, 2026

Copy link
Copy Markdown
Member

Adds a facility for giving bytecodes native "trampolines" so that they are visible by name in external backtraces (e.g. perf, gdb). Supersedes #1765. drmeister has done the work here, just filing a PR so I can review it.

Christian Schafmeisterr and others added 10 commits May 26, 2026 17:48
Arena-based trampolines (hand-coded x86_64), sampling profiler,
flame graph generation, trampoline-aware backtraces, command-line
extensions, and snapshot save/load support. Excludes bytecode
interpreter changes (computed gotos, VMDynRecord dynamic binding
stack) which remain on the interpreter-work branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Also demangle C++ function names
- New trampoline_aarch64.h paralleling trampoline_x86_64.h with
  hand-coded bytecode (36B) and GF (32B) trampolines using LDR
  from literal pool. Shared CIE and per-kind FDEs with full DWARF
  CFI for unwinding. Same instructions for Linux arm64 and Apple
  Silicon; macOS W^X support still needs MAP_JIT in ExecutableArena.
- Wire aarch64 templates into trampolineWork.cc via #elif __aarch64__.
- Demangle C++ symbols in sampling_profiler symbolicate_one via
  abi::__cxa_demangle for readable flame graph frames.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
At profile-start, snapshot /proc/self/maps (Linux) or dyld image list
(macOS) into a sorted executable-range cache. The SIGPROF handler
binary-searches each saved_rip during the frame-pointer walk: if the
address isn't in any executable mapping, the chain is broken (frame
compiled without -fno-omit-frame-pointer) and the walk stops cleanly
instead of following garbage pointers.

New JIT/arena pages registered dynamically via
sampling_profiler_add_executable_range(), called from
ExecutableArena::allocate() so trampolines mmap'd during profiling
are immediately recognized.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wraps a body form with sampling profiler start/stop and writes a
flame graph SVG on completion. Profiler is stopped and reset via
unwind-protect on any exit path.

  (ext:with-flame-profile ("/tmp/my.svg" :rate 197 :title "test")
    (expensive-work))

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The .dif file stored hash used to have to match the calculated hash
of the clasp_gc.sif file.  That's too restrictive

@Bike Bike left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly seems ok. some of the comments are false or misleading. I didn't read over the sampling profiler or flame graphs in great detail, but they're optional, so I'm not too concerned about those.

of course, tests are failing, so that's no good

Comment thread include/clasp/core/clasp_gmpxx.h
Comment thread include/clasp/core/sampling_profiler.h
Comment thread include/clasp/core/sampling_profiler.h Outdated
Comment thread src/core/trampoline/trampoline.cc Outdated
Comment thread src/core/trampoline/trampoline.cc Outdated
Comment thread src/llvmo/trampoline_arena.cc Outdated
Comment thread src/llvmo/trampoline_arena.cc
Comment thread src/lisp/kernel/lsp/flamegraph.lisp Outdated
Comment thread src/core/sampling_profiler.cc
Comment thread src/core/sampling_profiler.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants